package com.yaorange.teaching.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yaorange.common.log.annotation.Log;
import com.yaorange.common.log.enums.BusinessType;
import com.yaorange.common.security.annotation.RequiresPermissions;
import com.yaorange.teaching.domain.YaExamDetail;
import com.yaorange.teaching.service.IYaExamDetailService;
import com.yaorange.common.core.web.controller.BaseController;
import com.yaorange.common.core.web.domain.AjaxResult;
import com.yaorange.common.core.utils.poi.ExcelUtil;
import com.yaorange.common.core.web.page.TableDataInfo;

/**
 * 学生成绩详情Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/examdetail")
public class YaExamDetailController extends BaseController
{
    @Autowired
    private IYaExamDetailService yaExamDetailService;

    /**
     * 查询学生成绩详情列表
     */
    @RequiresPermissions("teaching:examdetail:list")
    @GetMapping("/list")
    public TableDataInfo list(YaExamDetail yaExamDetail)
    {
        startPage();
        List<YaExamDetail> list = yaExamDetailService.selectYaExamDetailList(yaExamDetail);
        return getDataTable(list);
    }

    /**
     * 导出学生成绩详情列表
     */
    @RequiresPermissions("teaching:examdetail:export")
    @Log(title = "学生成绩详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YaExamDetail yaExamDetail)
    {
        List<YaExamDetail> list = yaExamDetailService.selectYaExamDetailList(yaExamDetail);
        ExcelUtil<YaExamDetail> util = new ExcelUtil<YaExamDetail>(YaExamDetail.class);
        util.exportExcel(response, list, "学生成绩详情数据");
    }

    /**
     * 获取学生成绩详情详细信息
     */
    @RequiresPermissions("teaching:examdetail:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yaExamDetailService.selectYaExamDetailById(id));
    }

    /**
     * 新增学生成绩详情
     */
    @RequiresPermissions("teaching:examdetail:add")
    @Log(title = "学生成绩详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YaExamDetail yaExamDetail)
    {
        return toAjax(yaExamDetailService.insertYaExamDetail(yaExamDetail));
    }

    /**
     * 修改学生成绩详情
     */
    @RequiresPermissions("teaching:examdetail:edit")
    @Log(title = "学生成绩详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YaExamDetail yaExamDetail)
    {
        return toAjax(yaExamDetailService.updateYaExamDetail(yaExamDetail));
    }

    /**
     * 删除学生成绩详情
     */
    @RequiresPermissions("teaching:examdetail:remove")
    @Log(title = "学生成绩详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yaExamDetailService.deleteYaExamDetailByIds(ids));
    }
}
